Namespace States
    ''' <summary>
    ''' Undo Redo class. Contains saved states to recall to
    ''' </summary>
    ''' <remarks></remarks>
    Friend Class UnRedo
        Inherits ArrayList
        Private m_cursor As UInt32

        Public Overrides Sub Clear()
            MyBase.Clear()
            m_cursor = 0
        End Sub
        Public Overrides Function Add(ByVal value As Object) As Integer
            If m_cursor < Me.Count Then
                Me.RemoveRange(m_cursor, Me.Count - m_cursor)
            End If
            Dim f_return As Integer = MyBase.Add(value)
            m_cursor = Me.Count
        End Function
        Default Public Overrides Property Item(ByVal index As Integer) As Object
            Get
                Return MyBase.Item(index)
            End Get
            Set(ByVal value As Object)
                MyBase.Item(index) = value
            End Set
        End Property
    End Class

    Friend Class comboBoxItem
        Private m_Desc As String = ""
        Private m_value As Object = -1
        Sub New(ByVal sDescription As String, Optional ByVal dValue As Object = -1)
            m_Desc = sDescription
            m_value = dValue
        End Sub
        Public Property Description() As String
            Get
                Return m_Desc
            End Get
            Set(ByVal value As String)
                m_Desc = value
            End Set
        End Property
        Public Property Value() As Object
            Get
                Return m_value
            End Get
            Set(ByVal value As Object)
                m_value = value
            End Set
        End Property
        Public Overrides Function ToString() As String
            Return m_Desc
        End Function
    End Class

    Friend Class DataGridViewComboBoxCell2
        Inherits DataGridViewComboBoxCell

        Public Property SelectedIndex() As Integer
            Get
                Dim stringvalue As String = Me.Value.ToString
                If Me.Items.Count > 0 Then
                    For i As Integer = 0 To Me.Items.Count - 1
                        If CType(Me.Items(i), States.comboBoxItem).Description = StringValue Then Return i
                    Next
                End If
                Return -1
            End Get
            Set(ByVal value As Integer)
                If value < Me.Items.Count Then
                    Me.Value = Me.Items(value)
                End If
            End Set
        End Property
        Public Property SelectedValue() As Int32
            Get
                Dim stringvalue As String = Me.Value.ToString
                For Each item As States.comboBoxItem In Me.Items
                    If item.Description = StringValue Then Return item.Value
                Next
                Return -1
            End Get
            Set(ByVal value As Int32)
                For Each item As States.comboBoxItem In Me.Items
                    If item.Value = value Then
                        Me.Value = item
                        Return
                    End If
                Next
            End Set
        End Property

    End Class
End Namespace